<include file="./Tpl/Home/top.html"/>
<include file="./Tpl/Home/header.html" />
<!--交易页面的子导航区-->
<include file="./Tpl/Home/user_nav.html" />

<div class="container">
<!--全站交易记录-->
<div class="trade-part trade-part-hd mt20">
  <div class="trade-hd">
        <h5><i class="icon_condition"></i>账户提现</h5>
  </div>
  <div class="md">
    <div class="my-grid" id="order-grid" style="margin-bottom:20px;">
	    <form action="{$path}/User/tixian" method="post" id="formid">
			<table class="items table table-striped table-bordered table-condensed chkreal">
			<tbody>
			<tr>
				<td>币种：</td>
				<td>
				    <select id='typeid' name="typeid">
					    <volist name="types" id="vo">
					    <option value="{$vo.id}" <eq name="vo.tid" value="$vo.id">selected</eq>>{$vo.nickname}</option>
						</volist>
					</select>
					当前余额：<input type="text" name="coin" readonly style="width:150px;"/>
				</td>
			</tr>
			<tr><td>提现金额：</td><td><input type="text" name="goldnum" placeholder="只能在{$tixiand}-{$tixianu}元"/></td></tr>
			<tr><td>实际到帐：</td><td><input type="text" name="realnum" readonly value="0"/></td></tr>
			<tr><td>手续费：</td><td><input type="text" name="shouxu" readonly value="{$txfee}"/> %</td></tr>
			<tr>
                <td>提现地址：</td><td>
                <select name="url">
                <volist name="Arr" id="voA">
                    <option value="{$key}">{$voA}</option>
                </volist>
                </select>

            </td>
            </tr>
            <tr>
                <td>户主姓名：</td><td><input type="text" readonly value="{$username}"/>



            </td>

            </tr>
            </tr>
			<tr><td>交易密码：</td><td><input type="password" name="transpw" placeholder="请输入交易密码"/></td></tr>
			<tr><td>验证码：</td><td><input type="text" name="code" placeholder="请输入验证码" style="width:100px;"/><input type="button" value="发送验证码" class="btn" id="sendbtn"/></td></tr>
			<tr><td colspan=2><input type="button" id="subbtn" class="btn" value="确定" style="width:110px;"/></td></tr>
			</tbody>
			</table>
		</form>
	</div>
	<div class="my-grid" id="order-grid">
		<table class="items table table-striped table-bordered table-condensed saferoom">
		<thead>
		<tr><th>币种</th><th>金额</th><th>实际到帐</th><th>手续费</th><th>提现地址</th><th>时间</th><th width="10%">状态</th></tr>
		</thead>
		<tbody>
		<volist name="list" id="vo" empty="$empty">
		<tr><td class="chkTit">{$vo.nickname|default='无'}</td><td>{$vo.goldnum|default='0'}</td><td>{$vo.realnum|default='0'}</td><td>{$vo.shouxu|default='0'} %</td><td>{$vo.url|default='0'}</td><td>{$vo.addtime|default='无'}</td><td><eq name="vo.status" value="0">正在处理<else/>已处理</eq></td></tr>
		</volist>
		</tbody>
		</table>
	</div>
  </div>
</div>
</div>
<!--尾部-->
<include file="./Tpl/Home/footer.html" />
<!-- footer -->

<div class="modal hide fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>

<!--[if IE 6]><script src="/js/ie-6.js"></script><![endif]-->
<script type="text/javascript" src="/Public/Home/js/jquery.SuperSlide.js"></script>
<script type="text/javascript" src="/Public/Home/js/slideTxtBox.js"></script>
<script type="text/javascript" src="/Public/Home/js/bootbox.js"></script>
<script type="text/javascript" src="/Public/Home/js/box.js"></script>
<script type="text/javascript" src="/Public/Home/js/lang.js"></script>
<script type="text/javascript" src="/Public/Home/js/responseHandler.js"></script>
<script type="text/javascript" src="/Public/Home/js/jquery.yiigridview.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('body').popover({'selector':'a[rel=popover]'});
jQuery('#order-grid').yiiGridView({'ajaxUpdate':['order-grid'],'ajaxVar':'ajax','pagerClass':'pagination','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'items table table-striped table-bordered table-condensed','selectableRows':1,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'CurrencyTransaction_page'});
});
/*]]>*/

$(document).ready(function(){
    $('#typeid').change(function(){
        var flag="{$tixianflag}";
        if(flag){

            var Al=$(this).children('option:selected').val();
            if(Al!='5'){
                msgDalog('目前只支持人民币提现！');
                $("#subbtn").attr("disabled", true);
            }else{
                $("#subbtn").attr("disabled", false);
            }
        }
    })
});

$(document).ready(function(){
	$('#subbtn').click(function(){
		var goldnum = $('input[name=goldnum]').val();
	    if(goldnum=="" || goldnum <= 0){
		    msgDalog("请输入提现金额！","",0);
		}else if(isNaN(goldnum)){
			msgDalog('提现金额应该是数字！');
			$('input[name=goldnum]').val('');
			return false;
		}else if(goldnum>{$RMBYE}){
            msgDalog("提现不能超过你的余额里面的钱，你现在最多可提现{$RMBYE}元！","",0);
            $('input[name=goldnum]').val('');
            return false;
    }else if(goldnum < {$tixiand}||goldnum > {$tixianu}){

            msgDalog("提现金额必须在{$tixiand}-{$tixianu}元之间！","",0);
            $('input[name=goldnum]').val('');
            return false;
        }else if($('input[name=url]').val()==""){
		    msgDalog("你没有设置提现地址，请到钱包管理设置！","",0);
		}else if($('input[name=code]').val()==""){
		    msgDalog("请输入验证码！","",0);
		}else{
			var pos = goldnum.indexOf('.');
			if(pos != -1){
				if(goldnum.substring(0,pos)=='') {
					msgDalog('提现金额不合法！');
					return false;
				}
				len = goldnum.substring(pos+1,goldnum.length);
				if(len.length > 8) {
					msgDalog('提现金额小数位数不能超过8位！');
					return false;
				}
                $('#formid').submit();
			}else{
		        $('#formid').submit();
			}
		}
	});

	$('input[name=goldnum]').keyup(function(){

	    var goldnum = $('input[name=goldnum]').val();

		if(isNaN(goldnum)){
			msgDalog('提现金额应该是数字！');
			$('input[name=goldnum]').val('');
			return false;
		}

        var pos = goldnum.indexOf('.');
		if(pos != -1){

			if(goldnum.substring(0,pos)=='') {
				msgDalog('提现金额不合法！');
				$('input[name=goldnum]').focus();
				return false;
			}
			len = goldnum.substring(pos+1,goldnum.length);
			if(len.length > 8) {
				v = goldnum.substring(0,pos) + '.' + goldnum.substring(pos+1,pos+9);
				$('input[name=goldnum]').val(v);
				goldnum = v;
			}
		}

		var shouxu = $('input[name=shouxu]').val();
		realnum = goldnum - goldnum * shouxu / 100;
		if(realnum > 0) {
			realnum = String(realnum);
			var pos = realnum.indexOf('.');
			if(pos != -1){
				len = realnum.substring(pos+1,realnum.length);

				if(len.length > 8) {
					realnum = realnum.substring(0,pos) + '.' + realnum.substring(pos+1,pos+9);
				}
			}
		}

        $('input[name=realnum]').val(realnum);
	});

	$('input[name=goldnum]').change(function(){

	    var goldnum = $('input[name=goldnum]').val();

		if(isNaN(goldnum)){
			msgDalog('提现金额应该是数字！');
			$('input[name=goldnum]').val('');
			return false;
		}

        var pos = goldnum.indexOf('.');
		if(pos != -1){

			if(goldnum.substring(0,pos)=='') {
				msgDalog('提现金额不合法！');
				$('input[name=goldnum]').focus();
				return false;
			}
			len = goldnum.substring(pos+1,goldnum.length);
			if(len.length > 8) {
				v = goldnum.substring(0,pos) + '.' + goldnum.substring(pos+1,pos+9);
				$('input[name=goldnum]').val(v);
				goldnum = v;
			}
		}

		var shouxu = $('input[name=shouxu]').val();
		realnum = goldnum - goldnum * shouxu / 100;
		if(realnum > 0) {
			realnum = String(realnum);
			var pos = realnum.indexOf('.');
			if(pos != -1){
				len = realnum.substring(pos+1,realnum.length);

				if(len.length > 8) {
					realnum = realnum.substring(0,pos) + '.' + realnum.substring(pos+1,pos+9);
				}
			}
		}

        $('input[name=realnum]').val(realnum);
	});
});

$(document).ready(function(){
    $('#sendbtn').click(function(){
		$('#sendbtn').attr('disabled','disabled');
		var moble = "{$user_info.moble}";
		$.post('/?s=Home/Call/run',{phone:moble},function(flag){
			if(flag==1){
				alert('语音已开启，请注意查收验证码！');
			}else{
				alert('验证失败！请重新验证。');
			}
		});
	    var i=60;
		var si = setInterval(function(){
		    $('#sendbtn').val('（'+i+'）秒后可再次获取');

			if(i<=0) {
				clearInterval(si);
				$('#sendbtn').val('发送验证码');
				$('#sendbtn').attr('disabled',false);
			}
			i--;
		},1000);
	});

	var czurl = new Array();
	var czcoin = new Array();
	var czyuan = new Array();
	var rmbs = '';
	<volist name="types" id="vo">
	    czurl[{$vo.id}] = "{$vo.url}";
		czcoin[{$vo.id}] = "{$vo.coin}";
		czyuan[{$vo.id}] = "{$vo.yuan}";

		if({$vo.yuan}==1){
		    <volist name="vo.url" id="vv">
			rmbs += '<option value="'+"{$vv}"+'">'+"{$vv}"+'</option>';
			</volist>
		}
	</volist>
    $('select[name=typeid]').change(function(){
		if(czyuan[$(this).val()]==1){
			$('#urlshow').html('<select name="url">'+rmbs+'</select>');
		}else{
			$('#urlshow').html('<input type="text" name="url" readonly value="{$url}"/>');
			$('input[name=url]').val(czurl[$(this).val()]);
		}
		$('input[name=coin]').val(czcoin[$(this).val()]);
	});

	var typeid = $('select[name=typeid]').val();
	if(czyuan[typeid]==1){
		$('#urlshow').html('<select name="url">'+rmbs+'</select>');
	}else{
		$('#urlshow').html('<input type="text" name="url" readonly value="{$url}"/>');
		$('input[name=url]').val(czurl[typeid]);
	}

	$('input[name=coin]').val(czcoin[typeid]);
});
</script>


</body></html>